<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets" 
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" 
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:rich="http://richfaces.ajax4jsf.org/rich" 
	xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
	xmlns:t="https://code.google.com/p/rad-framework/taglib" 
	xmlns:tt="https://code.google.com/p/rad-framework"
	xmlns:s="http://jboss.com/products/seam/taglib">

	<rich:simpleTogglePanel id="filterTP"
		switchType="ajax" label="#{messages['Filters']}" opened="false" style="width:192px">

		<f:facet name="openMarker">
			<h:graphicImage value="/themes/default/images/rich-panel-header-max.gif" />
		</f:facet>
		<f:facet name="closeMarker">
			<h:graphicImage value="/themes/default/images/rich-panel-header-min.gif" />
		</f:facet>

		<h:panelGrid columns="2" width="100%">

			<a4j:commandLink id="search" action="#{finder.find}"
				eventsQueue="viewQ" reRender="searchTable,pagingGrid,quickSearchForm"
				styleClass="rad-framework-button-left">
				<s:defaultAction />
				<span>
					<h:outputText value="#{messages['Search']}" />
				</span>
			</a4j:commandLink>

			<a4j:commandLink id="clearFilter" eventsQueue="viewQ"
				action="#{finder.clearFilter}" reRender="filterTP,filterName" value="#{messages['Clear']}" />

		</h:panelGrid>

		<h:panelGrid columns="1" width="100%">

			<c:forEach id="stringParams" items="#{finder.filter.strings}" var="spm">
				<h:panelGrid columns="1" width="100%">
					<h:outputText value="#{spm.label}" styleClass="rad-framework-filter-label" />
					<h:inputText id="#{spm.name}Param" value="#{spm.value}" styleClass="rad-framework-form-input-field" />
				</h:panelGrid>
			</c:forEach>

			<c:forEach id="freeFormM2oParams" items="#{finder.filter.m2os}" var="mopm">
				<c:if test="#{mopm.freeForm}">
				<h:panelGrid columns="1" width="100%">
					<h:outputText value="#{mopm.label}" />
					<h:inputText id="#{mopm.name}Param" value="#{mopm.value}" styleClass="rad-framework-form-input-field" />
				</h:panelGrid>
				</c:if>
			</c:forEach>

			<c:forEach id="booleanParams" items="#{finder.filter.booleans}" var="bpm">
				<h:panelGrid columns="1" width="100%">
					<h:outputText value="#{bpm.label}" styleClass="rad-framework-filter-label" />
					<h:selectOneRadio id="#{bpm.name}Param" value="#{bpm.value}">
						<f:selectItem itemValue="EITHER" itemLabel="Either" />
						<f:selectItem itemValue="TRUE" itemLabel="True" />
						<f:selectItem itemValue="FALSE" itemLabel="False" />
					</h:selectOneRadio>
				</h:panelGrid>
			</c:forEach>

			<c:forEach id="dateParams" items="#{finder.filter.dates}" var="dpm">
				<h:panelGrid columns="1" width="100%">
					<h:outputText value="#{dpm.label} (From/To)"
						styleClass="rad-framework-filter-label" />
					<rich:calendar id="#{dpm.name}LHParam" value="#{dpm.lh}"
						locale="#{org.jboss.seam.core.locale}" 
						timeZone="#{org.jboss.seam.international.timeZone}"
						datePattern="MM/dd/yyyy" enableManualInput="true"
						inputClass="rad-framework-form-input-field">
					</rich:calendar>
					<rich:calendar id="#{dpm.name}RHParam" value="#{dpm.rh}"
						locale="#{org.jboss.seam.core.locale}" 
						timeZone="#{org.jboss.seam.international.timeZone}"
						datePattern="MM/dd/yyyy" enableManualInput="true"
						inputClass="rad-framework-form-input-field">
					</rich:calendar>
				</h:panelGrid>
			</c:forEach>

			<c:forEach id="numberParams" items="#{finder.filter.numbers}" var="npm">
				<h:panelGrid columns="1" width="100%">
					<h:outputText value="#{npm.label} (From/To)"
						styleClass="rad-framework-filter-label" />
					<h:inputText id="#{npm.name}LHParam" value="#{npm.lh}" 
						styleClass="rad-framework-form-input-field">
						<f:convertNumber />
					</h:inputText>
					<h:inputText id="#{npm.name}RHParam" value="#{npm.rh}" 
						styleClass="rad-framework-form-input-field">
						<f:convertNumber />
					</h:inputText>
				</h:panelGrid>
			</c:forEach>

			<c:forEach id="enumParams" items="#{finder.filter.enums}" var="epm">
				<h:panelGrid columns="1" width="100%">
					<h:outputText value="#{epm.label}" styleClass="rad-framework-filter-label" />
					<h:selectManyListbox id="#{epm.name}Param" value="#{epm.selected}"
						style="overflow:auto;width:100%">
						<f:selectItems value="#{epm.list}" />
					</h:selectManyListbox>
				</h:panelGrid>
			</c:forEach>

			<c:forEach id="m2oParams" items="#{finder.filter.m2os}" var="mopm">
				<c:if test="#{not mopm.freeForm}">
				<h:panelGrid columns="1" width="100%">
					<h:outputText value="#{mopm.label}" styleClass="rad-framework-filter-label" />
					<h:selectManyListbox id="#{mopm.name}Param" value="#{mopm.selected}"
						style="overflow:auto;width:100%;height:100px">
						<f:selectItems value="#{mopm.list}" />
					</h:selectManyListbox>
				</h:panelGrid>
				</c:if>
			</c:forEach>

			<c:forEach id="m2mParams" items="#{finder.filter.m2ms}" var="mmpm">
				<h:panelGrid columns="1" width="100%">
					<h:outputText value="#{mmpm.label}" styleClass="rad-framework-filter-label" />
					<h:selectManyListbox id="#{mmpm.name}Param" value="#{mmpm.selected}"
						style="overflow:auto;width:100%;height:100px">
						<f:selectItems value="#{mmpm.list}" />
					</h:selectManyListbox>
				</h:panelGrid>
			</c:forEach>

			<c:forEach id="o2mParams" items="#{finder.filter.o2ms}" var="ompm">
				<h:panelGrid columns="1" width="100%">
					<h:outputText value="#{ompm.label}" styleClass="rad-framework-filter-label" />
					<h:selectManyListbox id="#{ompm.name}Param" value="#{ompm.selected}"
						style="overflow:auto;width:100%;height:100px">
						<f:selectItems value="#{ompm.list}" />
					</h:selectManyListbox>
				</h:panelGrid>
			</c:forEach>

			<hr class="rad-framework-horizontal-separator" />

			<h:panelGrid columns="3" width="100%">
				<h:graphicImage value="/themes/default/images/icons/ico-sprite-star.png" />
				<h:outputText value="#{messages['PageSize']}" />
				<h:inputText value="#{pager.pageSize}" styleClass="rad-framework-form-input-field"
					size="4" />
			</h:panelGrid>

		</h:panelGrid>

	</rich:simpleTogglePanel>

</ui:composition>